Coder Social home page Coder Social logo

cyrildever / feistel Goto Github PK

View Code? Open in Web Editor NEW
14.0 1.0 1.0 1.06 MB

Feistel cipher implementation in Golang for format-preserving encryption

License: MIT License

Go 100.00%
cryptography algorithm encryption format-preserving-encryption xor-operation feistel-cipher fpe

feistel's People

Contributors

cyrildever avatar jmacd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

jmacd

feistel's Issues

Some Doubts About Format-Preserving Encryption

Wikipedia's definition of FPE as:

In cryptography, format-preserving encryption (FPE), refers to encrypting in such a way that the output (the ciphertext) is in the same format as the input (the plaintext). The meaning of "format" varies. Typically only finite sets of characters are used; numeric, alphabetic or alphanumeric. For example:

  • Encrypting a 16-digit credit card number so that the ciphertext is another 16-digit number.
  • Encrypting an English word so that the ciphertext is another English word.
  • Encrypting an n-bit number so that the ciphertext is another n-bit number (this is the definition of an n-bit block cipher).

However, the result obtained by encrypting the original data with Encrypt() does not seem to be in the same format as the original data.
For example, the encrypted number 123123123123, according to FPE, what I get should be a string of pure numbers, but what I actually get is `ZW±ªX^²[[®R.
Did we just keep the same length?

Fail to get an obfuscated string from a source data

My Test Code

	source := "my-source-data"
	cipher := feistel.NewFPECipher(hash.SHA_256, "some-32-byte-long-key-to-be-safe", 128)

	obfuscated, err := cipher.Encrypt(source)
	assert.NoError(t, err)
	str := obfuscated.String()
	fmt.Println(str)
	assert.Equal(t, len(source), len(str))

My Result

        	Error:      	Not equal: 
        	            	expected: 21
        	            	actual  : 14
        	Test:       	TestFormatPreservingEncryption

My OS

MacOS 12.6 M1

Version

github.com/cyrildever/feistel v1.3.21

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.