GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Worldpay/java-fpe: Java implementation of the FE1 Format Preserving Encryption algorithm.

BranchesTags
Open more actions menu

Latest commit

 

History

26 Commits
26 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
testsrc
testsrc
 
 
.checkstyle
.checkstyle
 
 
.gitignore
.gitignore
 
 
LICENSE.md
LICENSE.md
 
 
README.md
README.md
 
 
build.xml
build.xml
 
 
checkstyle.xml
checkstyle.xml
 
 
ivy.xml
ivy.xml
 
 

Repository files navigation

java-fpe

A Java implementation of Format Preserving Encryption using the FE1 scheme from the paper "Format-Preserving Encryption" by Bellare, Rogaway, et al.

Ported from DotFPE; which was ported from Botan Library Version 1.10.3.

See LICENSE.md for the full license.

Basic Usage

/**
 * Sample code to round trip a number using FE1.
 * @throws FPEException If anything goes wrong.
 */
public void demoRoundTrip() throws FPEException {
	FE1 fe1 = new FE1();
	
	// The range of plaintext and ciphertext values 
	BigInteger modulus = new BigInteger("9999999999999999", 10);
	
	// A value to encrypt 
	BigInteger plaintextValue = new BigInteger("4444333322221111", 10);
	
	// A key, that will be used with the HMAC(SHA256) algorithm, note that this is not secure!
	byte[] hmacKey = new byte[] { 0x10, 0x20, 0x10, 0x20, 0x10, 0x20, 0x10, 0x20};
	
	// An initialisation vector, or tweak, used in the algorithm.
	byte[] iv = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
	
	BigInteger encryptedValue = fe1.encrypt(modulus, plaintextValue, hmacKey, iv);
	BigInteger decryptedValue = fe1.decrypt(modulus, encryptedValue, hmacKey, iv);
	
	System.out.println(String.format("Encrypted %s to %s and decrypted to %s", plaintextValue, encryptedValue,decryptedValue));
}

How to build

You'll need Apache Ant and Apache Ivy to build. Running ant in the project root will download, build, package and run all the unit tests.

Note that the ant script includes calls to Git to pull the commit hash and version number (tag) from the repo when building a new distribution.

Dependencies

The main code (in src) doesn't have any dependencies outside of the standard Java APIs (including JCE extensions).

However, the unit tests make use of the following:

  1. Logback provides the logging implementation.
  2. slf4j provides the logging API.
  3. hamcrest-core-1.3 and Junit 4.11 provide unit test support.

See LICENSE.md for details of the associated licenses and restrictions associated with these dependencies.

Copyright

Copyright Worldpay Ltd.

About

Java implementation of the FE1 Format Preserving Encryption algorithm.

Topics

encryptionfe1fpejava

Resources

Readme
License
Activity
Custom properties

Stars

17 stars

Watchers

5 watching

Forks

4 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.