Get the SHA-256 signature of the input bytes.

@param bytes The input bytes (must not be <code>null</code>).
@return The bytes signature.
@throws LionEngineException If invalid arguments.
328387
public static String getSha(byte[] bytes)
    {
        Check.notNull(bytes);

        final StringBuilder builder = new StringBuilder(MAX_LENGTH);
        for (final byte b : SHA512.digest(bytes))
        {
            builder.append(0xFF & b);
        }
        return builder.toString();
    }
107448
public static HashCode fromBytes(byte[] bytes) {
        N.checkArgument(bytes.length >= 1, "A HashCode must contain at least 1 byte.");
        return fromBytesNoCopy(bytes.clone());
    }
801110
public static String toHex( byte[] bytes ) {
        StringBuffer buf = new StringBuffer();
        for( int i = 0; i < bytes.length; i++ ) {
            byte b = bytes[i];
            buf.append(toHexDigit((b >> 4) & 0x0F));
            buf.append(toHexDigit(b & 0x0F));
        }
        return buf.toString();
    }
727828
public static String sha1( String string ) {
        try {
            byte[] sha1 = SecureHash.getHash(SecureHash.Algorithm.SHA_1, string.getBytes());
            return SecureHash.asHexString(sha1);
        } catch (NoSuchAlgorithmException e) {
            throw new SystemFailureException(e);
        }
    }
1053976
public static String toHex(byte[] bytes) {
    final char[] string = new char[2 * bytes.length];
    int i = 0;
    for (byte b : bytes) {
      string[i++] = hexDigits[(b >> 4) & 0x0f];
      string[i++] = hexDigits[b & 0x0f];
    }
    return new String(string);
  }
169567
public static String toHex(final byte[] bytes) {
        if (bytes == null) {
            return "";
        }
        StringBuffer sb = new StringBuffer(bytes.length * 2);
        for (byte b : bytes) {
            appendHex(sb, b);
        }
        return sb.toString();
    }
677827
public byte[] getAnsiHash( byte[] challenge ) {
        if( hashesExternal ) {
            return ansiHash;
        }
        switch (LM_COMPATIBILITY) {
        case 0:
        case 1:
            return getPreNTLMResponse( password, challenge );
        case 2:
            return getNTLMResponse( password, challenge );
        case 3:
        case 4:
        case 5:
            if( clientChallenge == null ) {
                clientChallenge = new byte[8];
                RANDOM.nextBytes( clientChallenge );
            }
            return getLMv2Response(domain, username, password, challenge,
                    clientChallenge);
        default:
            return getPreNTLMResponse( password, challenge );
        }
    }
676516
@Nonnull
    public static String toHex(@Nonnull final byte[] bytes) {
        StringBuilder buf = new StringBuilder(bytes.length * 2);
        for (byte b : bytes) {
            String hexDigits = Integer.toHexString((int) b & 0x00ff);
            if (hexDigits.length() == 1) {
                buf.append('0');
            }
            buf.append(hexDigits);
        }
        return buf.toString();
    }
923663
public static String getSignatureHexCode(Context context, String targetPackageName) {
        if (TextUtils.isEmpty(targetPackageName)) {
            return null;
        }
        try {
            PackageInfo info = PackageManagerUtils.getSignaturePackageInfo(context, targetPackageName);
            if (info.signatures.length != 1) {
                // multiple signature would not treated
                return null;
            }
            Signature sig = info.signatures[0];
            byte[] sha256 = MessageDigestUtils.computeSha256(sig.toByteArray());
            return StringUtils.byteToHex(sha256);
        } catch (NameNotFoundException e) {
            Log.e(TAG, "target package not found: ", e);
            return null;
        }
    }
279128
public static byte[] sha256Bytes(byte[] bs) {
        if (bs == null) return null;
        MessageDigest digester;
        try {
            digester = MessageDigest.getInstance("SHA-256");
        } catch (NoSuchAlgorithmException ex) {
            throw new RuntimeException(ex);
        }
        return digester.digest(bs);
    }
771502
public static String toHex(byte[] bytes) {
    StringBuffer buffer = new StringBuffer();

    for (byte b : bytes) {
      buffer.append(String.format("%02X", b));
    }

    return buffer.toString();
  }
1282372
public static char[] bytes2Chars(final byte[] bytes) {
        if (bytes == null) return null;
        int len = bytes.length;
        if (len <= 0) return null;
        char[] chars = new char[len];
        for (int i = 0; i < len; i++) {
            chars[i] = (char) (bytes[i] & 0xff);
        }
        return chars;
    }
553568
public String sign(final String message) throws EncryptionException {
      try {
         Signature sign = Signature.getInstance("SHA1withRSA");
         sign.initSign(privateKey);
         sign.update(message.getBytes(DEFAULT_CHARSET));

         return new String(Base64.encodeBase64(sign.sign()), DEFAULT_CHARSET);
      } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) {
         throw new EncryptionException("Unable to sign message: ", e);
      }
   }
1093708
def _get_signature(self, entry):
        

        if self._sha1_sigs:
            # return sha1 digest of the file content...
            if not os.path.exists(entry.filename):
                return None
            try:
                with open(entry.filename, "r") as f:
                    data = f.read()
                    return hashlib.sha1(data.encode("utf-8")).digest()
            except IOError as e:
                print("Cannot determine sha1 digest:", e)
                return None
        else:
            # return file modification date...
            try:
                return os.path.getmtime(entry.filename)
            except OSError:
                return None
37382
public static ECKey signatureToKey(byte[] messageHash, String signatureBase64) throws SignatureException {
        final byte[] keyBytes = signatureToKeyBytes(messageHash, signatureBase64);
        return ECKey.fromPublicOnly(keyBytes);
    }
456
static byte[] sha1(InputStream in) {
    try {
      MessageDigest md = MessageDigest.getInstance(SHA1_DIGEST); 
      byte[] buffer = new byte[4096];
      int bytes;
      while ( (bytes = in.read(buffer)) > 0) {
        md.update(buffer, 0, bytes);
      }
      return md.digest();
    }
    catch(NoSuchAlgorithmException | IOException e) {
      throw new InternalErrorException(e);
    }
  }
590891
public static byte[] sign(
      Signature signatureAlgorithm, PrivateKey privateKey, byte[] contentBytes)
      throws InvalidKeyException, SignatureException {
    signatureAlgorithm.initSign(privateKey);
    signatureAlgorithm.update(contentBytes);
    return signatureAlgorithm.sign();
  }