Created
September 5, 2012 14:04
-
-
Save lyhcode/3637109 to your computer and use it in GitHub Desktop.
Groovy + DES Encryption
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.security.* | |
import javax.crypto.* | |
import javax.crypto.spec.* | |
def source = new File('input.dat').text | |
def cipher = Cipher.getInstance('DES') | |
cipher.init(Cipher.ENCRYPT_MODE, SecretKeyFactory.getInstance('DES').generateSecret(new DESKeySpec('secret12'.getBytes('UTF-8')))) | |
def target = cipher.doFinal(source.bytes).encodeBase64() | |
new File('output.dat').write('${target}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment