Last active
August 29, 2015 14:21
-
-
Save frankvilhelmsen/1aad4287e8d216e00499 to your computer and use it in GitHub Desktop.
create request with an encrypted token
This file contains 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
/* create token for accessing service */ | |
format = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ") | |
timestamp = format.format(new Date(System.currentTimeMillis())) | |
sks = new javax.crypto.spec.SecretKeySpec("OuH5pmYeLIkqiirwiyvY+w==".getBytes(), "AES") | |
cip = javax.crypto.Cipher.getInstance("AES") | |
cip.init(javax.crypto.Cipher.ENCRYPT_MODE, sks, cip.getParameters()); | |
raw = cip.doFinal( timestamp.getBytes() ); | |
println "Token..: ${raw.encodeBase64()} " | |
http://blog.dornea.nu/2014/07/01/on-java-openssl-crypto-blowfish-and-stuff/ | |
String.metaClass.tohex = { -> | |
return String.format("%x", new BigInteger(1, delegate.getBytes(/*YOUR_CHARSET?*/))); | |
} | |
println "timestamp".tohex() | |
// echo "timestamp" | openssl enc -aes128 -pass pass:OuH5pmYeLIkqiirwiyvY+w== -p -nosalt -a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment