1 | <?php |
||
11 | class ThreemaGateway_Helper_Key |
||
12 | { |
||
13 | /** |
||
14 | * Returns the public key of a Threema ID. |
||
15 | * |
||
16 | * XenForo template helper: threemaidpubkey. |
||
17 | * |
||
18 | * @param string $threemaid Threema ID |
||
19 | * @throws XenForo_Exception |
||
20 | * @return string |
||
21 | */ |
||
22 | public static function getPublic($threemaid) |
||
39 | |||
40 | /** |
||
41 | * Returns the short (user friendly) hash of the public key of a Threema ID. |
||
42 | * |
||
43 | * XenForo template helper: threemaidpubkeyshort. |
||
44 | * Do not confuse this with {@link getUserDisplay()}. Here you have to pass |
||
45 | * the Threema Id! |
||
46 | * |
||
47 | * @param string $threemaid Threema ID |
||
48 | * @return string |
||
49 | */ |
||
50 | public static function getPublicShort($threemaid) |
||
57 | |||
58 | /** |
||
59 | * Checks whether a public key is valid. |
||
60 | * |
||
61 | * XenForo template helper: threemaisvalidpubkey. |
||
62 | * |
||
63 | * @param string $pubKey Threema ID |
||
64 | * @return bool |
||
65 | */ |
||
66 | public static function checkPublic($pubKey) |
||
70 | |||
71 | /** |
||
72 | * Checks whether a HEX-key is valid. |
||
73 | * |
||
74 | * XenForo template helper: threemaisvalidkey. |
||
75 | * |
||
76 | * @param string $publicKey the public key in hex |
||
77 | * @param string $suffix optional suffix (usually 'private:' or 'public:') (default: '') |
||
78 | * |
||
79 | * @return bool whether the key is valid (true) or not (false) |
||
80 | */ |
||
81 | public static function check($publicKey, $suffix = '') |
||
86 | |||
87 | /** |
||
88 | * Returns the short user-friendly hash of the public key. |
||
89 | * |
||
90 | * XenForo template helper: threemashortpubkey. |
||
91 | * Do not confuse this with {@link getPublicShort()}. Here you have to pass |
||
92 | * the public key! |
||
93 | * This is the way the key is also displayed in the Threema app. For example |
||
94 | * ECHOECHO is shown as `d30f795a904a213578baecc62c8611b5`. However the |
||
95 | * full public key of it is: |
||
96 | * `4a6a1b34dcef15d43cb74de2fd36091be99fbbaf126d099d47d83d919712c72b` |
||
97 | * |
||
98 | * @param string $publicKey The public key to format. |
||
99 | * |
||
100 | * @return string 32 hex characters |
||
101 | */ |
||
102 | public static function getUserDisplay($publicKey) |
||
113 | |||
114 | /** |
||
115 | * Removes the suffix if necessary. |
||
116 | * |
||
117 | * XenForo template helper: threemakeyremovesuffix. |
||
118 | * |
||
119 | * @param string $keyHex The key in hex |
||
120 | * @return string |
||
121 | */ |
||
122 | public static function removeSuffix($keyHex) |
||
132 | } |
||
133 |