play.utils.ErrorsCookieCrypter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of framework Show documentation
Show all versions of framework Show documentation
RePlay is a fork of the Play1 framework, created by Codeborne.
package play.utils;
import play.libs.Crypter;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
@ParametersAreNonnullByDefault
public class ErrorsCookieCrypter {
private final Crypter crypter = new Crypter("errors-");
@Nonnull
@CheckReturnValue
public String encrypt(String errorsCookie) {
return crypter.encryptAES(Math.random() + ":" + errorsCookie);
}
@Nonnull
@CheckReturnValue
public String decrypt(String errorsCookie) {
String decryptCookie = crypter.decryptAES(errorsCookie);
return decryptCookie.substring(decryptCookie.indexOf(':') + 1);
}
}