Java Code Examples for com.helger.commons.string.StringHelper#getHexEncoded()

The following examples show how to use com.helger.commons.string.StringHelper#getHexEncoded() . 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: XMLWriterSettings.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Override
public String toString ()
{
  if (m_sIndentationStringToString == null)
    m_sIndentationStringToString = StringHelper.getHexEncoded (m_sIndentationString.getBytes (StandardCharsets.ISO_8859_1));
  return new ToStringGenerator (this).append ("SerializeVersion", m_eSerializeVersion)
                                     .append ("SerializeXMLDecl", m_eSerializeXMLDecl)
                                     .append ("NewLineAfterXMLDeclaration", m_bNewLineAfterXMLDeclaration)
                                     .append ("SerializeDocType", m_eSerializeDocType)
                                     .append ("SerializeComments", m_eSerializeComments)
                                     .append ("Indent", m_eIndent)
                                     .append ("IndentDeterminator", m_aIndentDeterminator)
                                     .append ("IncorrectCharHandling", m_eIncorrectCharacterHandling)
                                     .append ("Charset", m_aCharset)
                                     .append ("NamespaceContext", m_aNamespaceContext)
                                     .append ("DoubleQuotesForAttrs", m_bUseDoubleQuotesForAttributes)
                                     .append ("BracketModeDeterminator", m_aBracketModeDeterminator)
                                     .append ("SpaceOnSelfClosedElement", m_bSpaceOnSelfClosedElement)
                                     .append ("NewlineMode", m_eNewLineMode)
                                     .append ("IndentationString", m_sIndentationStringToString)
                                     .append ("EmitNamespaces", m_bEmitNamespaces)
                                     .append ("PutNamespaceContextPrefixesInRoot",
                                              m_bPutNamespaceContextPrefixesInRoot)
                                     .append ("WriteCDATAAsText", m_bWriteCDATAAsText)
                                     .append ("OrderAttributesAndNamespaces", m_bOrderAttributesAndNamespaces)
                                     .getToString ();
}
 
Example 2
Source File: AuthTokenIDGenerator.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static String generateNewTokenID (@Nonnegative final int nBytes)
{
  final byte [] aID = new byte [nBytes];
  ThreadLocalRandom.current ().nextBytes (aID);
  return StringHelper.getHexEncoded (aID);
}
 
Example 3
Source File: AbstractPasswordHashCreatorPBKDF2.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nonnull
public String createPasswordHash (@Nonnull final IPasswordSalt aSalt, @Nonnull final String sPlainTextPassword)
{
  ValueEnforcer.notNull (aSalt, "Salt");
  ValueEnforcer.notNull (sPlainTextPassword, "PlainTextPassword");

  final byte [] aDigest = pbkdf2 (sPlainTextPassword.toCharArray (),
                                  aSalt.getSaltBytes (),
                                  m_nIterations,
                                  m_nHashBytes);
  return StringHelper.getHexEncoded (aDigest);
}
 
Example 4
Source File: PasswordSalt.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor to create a new password salt with the provided byte count.
 *
 * @param nSaltBytes
 *        The number of salt bytes to use. Must be > 0.
 */
public PasswordSalt (@Nonnegative final int nSaltBytes)
{
  ValueEnforcer.isGT0 (nSaltBytes, "SaltBytes");
  m_aBytes = new byte [nSaltBytes];
  new Random ().nextBytes (m_aBytes);
  m_sSalt = StringHelper.getHexEncoded (m_aBytes);
}
 
Example 5
Source File: IHasByteArray.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
/**
 * @return The hex encoded version of this string. Never <code>null</code> but
 *         maybe empty, if the underlying array length is empty.
 */
@Nonnull
default String getHexEncoded ()
{
  return StringHelper.getHexEncoded (bytes (), getOffset (), size ());
}
 
Example 6
Source File: PasswordSalt.java    From ph-commons with Apache License 2.0 4 votes vote down vote up
private PasswordSalt (@Nonnull @Nonempty final byte [] aBytes)
{
  ValueEnforcer.notEmpty (aBytes, "Bytes");
  m_aBytes = aBytes;
  m_sSalt = StringHelper.getHexEncoded (aBytes);
}