@@ -6,6 +6,7 @@ public class FingerprintUtil
66 /**
77 * Derive a 64 bit key-id from a version 6 OpenPGP fingerprint.
88 * For v6 keys, the key-id corresponds to the left-most 8 octets of the fingerprint.
9+ *
910 * @param v6Fingerprint 32 byte fingerprint
1011 * @return key-id
1112 */
@@ -17,6 +18,7 @@ public static long keyIdFromV6Fingerprint(byte[] v6Fingerprint)
1718 /**
1819 * Derive a 64 bit key-id from a version 5 LibrePGP fingerprint.
1920 * For such keys, the key-id corresponds to the left-most 8 octets of the fingerprint.
21+ *
2022 * @param v5Fingerprint 32 byte fingerprint
2123 * @return key-id
2224 */
@@ -28,6 +30,7 @@ public static long keyIdFromLibrePgpFingerprint(byte[] v5Fingerprint)
2830 /**
2931 * Derive a 64 bit key-id from a version 4 OpenPGP fingerprint.
3032 * For v4 keys, the key-id corresponds to the right-most 8 octets of the fingerprint.
33+ *
3134 * @param v4Fingerprint 20 byte fingerprint
3235 * @return key-id
3336 */
@@ -38,6 +41,7 @@ public static long keyIdFromV4Fingerprint(byte[] v4Fingerprint)
3841
3942 /**
4043 * Convert the left-most 8 bytes from the given array to a long.
44+ *
4145 * @param bytes bytes
4246 * @return long
4347 */
@@ -47,18 +51,19 @@ public static long longFromLeftMostBytes(byte[] bytes)
4751 {
4852 throw new IllegalArgumentException ("Byte array MUST contain at least 8 bytes" );
4953 }
50- return ((bytes [0 ] & 0xffL ) << 56 ) |
51- ((bytes [1 ] & 0xffL ) << 48 ) |
52- ((bytes [2 ] & 0xffL ) << 40 ) |
53- ((bytes [3 ] & 0xffL ) << 32 ) |
54- ((bytes [4 ] & 0xffL ) << 24 ) |
55- ((bytes [5 ] & 0xffL ) << 16 ) |
56- ((bytes [6 ] & 0xffL ) << 8 ) |
57- ((bytes [7 ] & 0xffL ));
54+ return ((bytes [0 ] & 0xffL ) << 56 ) |
55+ ((bytes [1 ] & 0xffL ) << 48 ) |
56+ ((bytes [2 ] & 0xffL ) << 40 ) |
57+ ((bytes [3 ] & 0xffL ) << 32 ) |
58+ ((bytes [4 ] & 0xffL ) << 24 ) |
59+ ((bytes [5 ] & 0xffL ) << 16 ) |
60+ ((bytes [6 ] & 0xffL ) << 8 ) |
61+ ((bytes [7 ] & 0xffL ));
5862 }
5963
6064 /**
6165 * Convert the right-most 8 bytes from the given array to a long.
66+ *
6267 * @param bytes bytes
6368 * @return long
6469 */
@@ -69,13 +74,13 @@ public static long longFromRightMostBytes(byte[] bytes)
6974 throw new IllegalArgumentException ("Byte array MUST contain at least 8 bytes" );
7075 }
7176 int i = bytes .length ;
72- return ((bytes [i - 8 ] & 0xffL ) << 56 ) |
73- ((bytes [i - 7 ] & 0xffL ) << 48 ) |
74- ((bytes [i - 6 ] & 0xffL ) << 40 ) |
75- ((bytes [i - 5 ] & 0xffL ) << 32 ) |
76- ((bytes [i - 4 ] & 0xffL ) << 24 ) |
77- ((bytes [i - 3 ] & 0xffL ) << 16 ) |
78- ((bytes [i - 2 ] & 0xffL ) << 8 ) |
79- ((bytes [i - 1 ] & 0xffL ));
77+ return ((bytes [i - 8 ] & 0xffL ) << 56 ) |
78+ ((bytes [i - 7 ] & 0xffL ) << 48 ) |
79+ ((bytes [i - 6 ] & 0xffL ) << 40 ) |
80+ ((bytes [i - 5 ] & 0xffL ) << 32 ) |
81+ ((bytes [i - 4 ] & 0xffL ) << 24 ) |
82+ ((bytes [i - 3 ] & 0xffL ) << 16 ) |
83+ ((bytes [i - 2 ] & 0xffL ) << 8 ) |
84+ ((bytes [i - 1 ] & 0xffL ));
8085 }
8186}
0 commit comments