org.apache.shiro.crypto.hash.Hash.getBytes()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中org.apache.shiro.crypto.hash.Hash.getBytes()方法的一些代码示例,展示了Hash.getBytes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hash.getBytes()方法的具体详情如下:
包路径:org.apache.shiro.crypto.hash.Hash
类名称:Hash
方法名:getBytes

Hash.getBytes介绍

暂无

代码示例

代码示例来源:origin: apache/shiro

/**
 * Returns {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to
 * this Hash's byte array, {@code false} otherwise.
 *
 * @param o the object (Hash) to check for equality.
 * @return {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to
 *         this Hash's byte array, {@code false} otherwise.
 */
public boolean equals(Object o) {
  if (o instanceof Hash) {
    Hash other = (Hash) o;
    return MessageDigest.isEqual(getBytes(), other.getBytes());
  }
  return false;
}

代码示例来源:origin: apache/shiro

/**
 * Returns {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to
 * this Hash's byte array, {@code false} otherwise.
 *
 * @param o the object (Hash) to check for equality.
 * @return {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to
 *         this Hash's byte array, {@code false} otherwise.
 */
public boolean equals(Object o) {
  if (o instanceof Hash) {
    Hash other = (Hash) o;
    return MessageDigest.isEqual(getBytes(), other.getBytes());
  }
  return false;
}

代码示例来源:origin: apache/shiro

result.setBytes(computed.getBytes());
result.setIterations(iterations);

代码示例来源:origin: com.manydesigns/portofino-pageactions

@Override
  public String format(Hash hash) {
    return new String(hash.getBytes());
  }
}

代码示例来源:origin: ManyDesigns/Portofino

@Override
  public String format(Hash hash) {
    return new String(hash.getBytes());
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

/**
 * Returns {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to
 * this Hash's byte array, {@code false} otherwise.
 *
 * @param o the object (Hash) to check for equality.
 * @return {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to
 *         this Hash's byte array, {@code false} otherwise.
 */
public boolean equals(Object o) {
  if (o instanceof Hash) {
    Hash other = (Hash) o;
    return Arrays.equals(getBytes(), other.getBytes());
  }
  return false;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro

/**
 * Returns {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to
 * this Hash's byte array, {@code false} otherwise.
 *
 * @param o the object (Hash) to check for equality.
 * @return {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to
 *         this Hash's byte array, {@code false} otherwise.
 */
public boolean equals(Object o) {
  if (o instanceof Hash) {
    Hash other = (Hash) o;
    return Arrays.equals(getBytes(), other.getBytes());
  }
  return false;
}

代码示例来源:origin: dschadow/JavaSecurity

public static void main(String[] args) {
  String password = "SHA-512 hash sample text";
  Hash hash = calculateHash(password);
  boolean correct = verifyPassword(hash.getBytes(), hash.getSalt(), password);
  log.info("Entered password is correct: {}", correct);
}

代码示例来源:origin: org.apache.shiro/shiro-crypto-hash

/**
 * Returns {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to
 * this Hash's byte array, {@code false} otherwise.
 *
 * @param o the object (Hash) to check for equality.
 * @return {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to
 *         this Hash's byte array, {@code false} otherwise.
 */
public boolean equals(Object o) {
  if (o instanceof Hash) {
    Hash other = (Hash) o;
    return MessageDigest.isEqual(getBytes(), other.getBytes());
  }
  return false;
}

代码示例来源:origin: org.apache.shiro/shiro-crypto-hash

/**
 * Returns {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to
 * this Hash's byte array, {@code false} otherwise.
 *
 * @param o the object (Hash) to check for equality.
 * @return {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to
 *         this Hash's byte array, {@code false} otherwise.
 */
public boolean equals(Object o) {
  if (o instanceof Hash) {
    Hash other = (Hash) o;
    return MessageDigest.isEqual(getBytes(), other.getBytes());
  }
  return false;
}

代码示例来源:origin: dschadow/JavaSecurity

private static boolean verifyPassword(byte[] originalHash, ByteSource publicSalt, String password) {
    ByteSource privateSalt = ByteSource.Util.bytes(PRIVATE_SALT_BYTES);
    DefaultHashService hashService = new DefaultHashService();
    hashService.setPrivateSalt(privateSalt);
    hashService.setHashIterations(ITERATIONS);

    HashRequest.Builder builder = new HashRequest.Builder();
    builder.setSource(ByteSource.Util.bytes(password));
    builder.setSalt(publicSalt);

    Hash comparisonHash = hashService.computeHash(builder.build());

    log.info("password: {}", password);
    log.info("1 hash: {}", Hex.encodeToString(originalHash));
    log.info("2 hash: {}", comparisonHash.toHex());

    return Arrays.equals(originalHash, comparisonHash.getBytes());
  }
}

代码示例来源:origin: org.apache.shiro/shiro-crypto-hash

result.setBytes(computed.getBytes());
result.setIterations(iterations);

相关文章

微信公众号

最新文章

更多