Java Code Examples for org.apache.shiro.codec.Hex#encodeToString()
The following examples show how to use
org.apache.shiro.codec.Hex#encodeToString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MySimpleHash.java From cms with Apache License 2.0 | 6 votes |
protected byte[] hash(byte[] bytes, byte[] salt, int hashIterations) throws UnknownAlgorithmException { String toB = new String(bytes); String toS = new String(salt); String name = this.getAlgorithmName(); MessageDigest digest = this.getDigest(this.getAlgorithmName()); if (salt != null) { digest.reset(); digest.update(salt); } byte[] hashed = digest.digest(bytes); String toH = Hex.encodeToString(hashed); int iterations = hashIterations - 1; for(int i = 0; i < iterations; ++i) { digest.reset(); hashed = digest.digest(hashed); } toH = Hex.encodeToString(hashed); return hashed; }
Example 2
Source File: ShiroByteSource.java From xmanager with Apache License 2.0 | 5 votes |
@Override public String toHex() { if ( this.cachedHex == null ) { this.cachedHex = Hex.encodeToString(getBytes()); } return this.cachedHex; }
Example 3
Source File: MySimpleHash.java From cms with Apache License 2.0 | 5 votes |
public String toHex() { if (this.hexEncoded == null) { this.hexEncoded = Hex.encodeToString(this.getBytes()); } return this.hexEncoded; }
Example 4
Source File: AbstractHash.java From nano-framework with Apache License 2.0 | 5 votes |
/** * * @return a hex-encoded string of the underlying {@link #getBytes byte array}. */ public String toHex() { if (this.hexEncoded == null) { this.hexEncoded = Hex.encodeToString(getBytes()); } return this.hexEncoded; }
Example 5
Source File: SimpleHash.java From nano-framework with Apache License 2.0 | 5 votes |
/** * * @return a hex-encoded string of the underlying {@link #getBytes byte array}. */ public String toHex() { if (this.hexEncoded == null) { this.hexEncoded = Hex.encodeToString(getBytes()); } return this.hexEncoded; }
Example 6
Source File: MySimpleHash.java From cms with Apache License 2.0 | 4 votes |
private void hash(ByteSource source, ByteSource salt, int hashIterations) throws CodecException, UnknownAlgorithmException { byte[] saltBytes = salt != null ? salt.getBytes() : null; byte[] hashedBytes = this.hash(source.getBytes(), saltBytes, hashIterations); String toH= Hex.encodeToString(hashedBytes); this.setBytes(hashedBytes); }
Example 7
Source File: MySimpleByteSource.java From VideoMeeting with Apache License 2.0 | 4 votes |
public String toHex() { if (this.cachedHex == null) { this.cachedHex = Hex.encodeToString(getBytes()); } return this.cachedHex; }
Example 8
Source File: SimpleByteSource.java From nano-framework with Apache License 2.0 | 4 votes |
public String toHex() { if ( this.cachedHex == null ) { this.cachedHex = Hex.encodeToString(getBytes()); } return this.cachedHex; }
Example 9
Source File: EndecryptUtil.java From LazyREST with Apache License 2.0 | 2 votes |
/** * 16进制加密 * * @param content * @return */ public static String encrytHex(String content) { Preconditions.checkArgument(!Strings.isNullOrEmpty(content), "不能为空"); byte[] bytes = content.getBytes(); return Hex.encodeToString(bytes); }