
com.cryptoregistry.tweet.pepper.key.Key Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tweetpepper Show documentation
Show all versions of tweetpepper Show documentation
Built on the nucleus of TweetNaCl, TweetPepper provides contemporary key formats, key protection using SCrypt/SecretBox, digital signature support scheme featuring CubeHash, key encapsulation using Salsa20, and other useful features you probably want anyway.
The newest version!
/*
Copyright 2016, David R. Smith, All Rights Reserved
This file is part of TweetPepper.
TweetPepper is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
TweetPepper is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TweetPepper. If not, see .
*/
package com.cryptoregistry.tweet.pepper.key;
import java.util.Arrays;
import java.util.Base64;
/**
* Base class to wrap bytes used as keys
*
* @author Dave
* @see CryptoFactory
*/
public class Key {
// actual key bytes
protected final byte [] bytes;
// status of the key
protected boolean alive = true;
public Key(byte [] bytes) {
this.bytes = bytes;
}
protected Key(byte [] bytes, boolean alive) {
this.bytes = bytes;
this.alive = alive;
}
public byte[] getBytes() {
if(!alive) throw new DeadKeyException();
return bytes;
}
public String getEncoded() {
if(!alive) throw new DeadKeyException();
return Base64.getUrlEncoder().encodeToString(bytes);
}
public void selfDestruct() {
for(int i = 0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy