-
Notifications
You must be signed in to change notification settings - Fork 890
Add examples to Sodium base64 functions #5866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,81 @@ | |
| </simpara> | ||
| </refsect1> | ||
|
|
||
| <refsect1 role="examples"><!-- {{{ --> | ||
| &reftitle.examples; | ||
| <example xml:id="sodium-base642bin.example.basic"><!-- {{{ --> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On top of the comment, no need to include xml:id for (all of the) examples. |
||
| <title><function>sodium_base642bin</function> example</title> | ||
| <programlisting role="php"> | ||
| <![CDATA[ | ||
| <?php | ||
| $string = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw=='; | ||
| echo sodium_base642bin($string, SODIUM_BASE64_VARIANT_ORIGINAL); | ||
| ?> | ||
| ]]> | ||
| </programlisting> | ||
| &example.outputs; | ||
| <screen> | ||
| <![CDATA[ | ||
| This is an encoded string | ||
| ]]> | ||
| </screen> | ||
| </example><!-- }}} --> | ||
|
|
||
| <example xml:id="sodium-base642bin.example.id"><!-- {{{ --> | ||
| <title>Example of the <parameter>id</parameter> parameter</title> | ||
| <programlisting role="php"> | ||
| <![CDATA[ | ||
| <?php | ||
| var_dump(sodium_bin2hex(sodium_base642bin('rrZ5j+9OUYT/O1WWr3U0hw==', SODIUM_BASE64_VARIANT_ORIGINAL))); | ||
| var_dump(sodium_bin2hex(sodium_base642bin('rrZ5j+9OUYT/O1WWr3U0hw', SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING))); | ||
| var_dump(sodium_bin2hex(sodium_base642bin('rrZ5j-9OUYT_O1WWr3U0hw==', SODIUM_BASE64_VARIANT_URLSAFE))); | ||
| var_dump(sodium_bin2hex(sodium_base642bin('rrZ5j-9OUYT_O1WWr3U0hw', SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING))); | ||
| ?> | ||
| ]]> | ||
| </programlisting> | ||
| &example.outputs; | ||
| <screen> | ||
| <![CDATA[ | ||
| string(32) "aeb6798fef4e5184ff3b5596af753487" | ||
| string(32) "aeb6798fef4e5184ff3b5596af753487" | ||
| string(32) "aeb6798fef4e5184ff3b5596af753487" | ||
| string(32) "aeb6798fef4e5184ff3b5596af753487" | ||
| ]]> | ||
| </screen> | ||
| </example><!-- }}} --> | ||
|
|
||
| <example xml:id="sodium-base642bin.example.ignore"><!-- {{{ --> | ||
| <title>Example of the <parameter>ignore</parameter> parameter</title> | ||
| <programlisting role="php"> | ||
| <![CDATA[ | ||
| <?php | ||
| $string = <<<'STR' | ||
| VGhpcyBpcy | ||
| BhbiBlbmNv | ||
| ZGVkIHN0cm | ||
| luZw== | ||
| STR; | ||
| var_dump(sodium_base642bin($string, SODIUM_BASE64_VARIANT_ORIGINAL, " \r\n")); | ||
| ?> | ||
| ]]> | ||
| </programlisting> | ||
| &example.outputs; | ||
| <screen> | ||
| <![CDATA[ | ||
| string(25) "This is an encoded string" | ||
| ]]> | ||
| </screen> | ||
| </example><!-- }}} --> | ||
| </refsect1><!-- }}} --> | ||
|
|
||
| <refsect1 role="seealso"><!-- {{{ --> | ||
| &reftitle.seealso; | ||
| <simplelist> | ||
| <member><function>base64_decode</function></member> | ||
| <member><function>sodium_bin2base64</function></member> | ||
| <member><function>sodium_bin2hex</function></member> | ||
| </simplelist> | ||
| </refsect1><!-- }}} --> | ||
|
|
||
| </refentry> | ||
| <!-- Keep this comment at the end of the file | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,59 @@ | |
| </simpara> | ||
| </refsect1> | ||
|
|
||
| <refsect1 role="examples"><!-- {{{ --> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as Can you please remove all the comments in this file? , etc. In the past this was used more often but nowadays we try to avoid it as it makes the XML harder to read. |
||
| &reftitle.examples; | ||
| <example xml:id="sodium-bin2base64.example.basic"><!-- {{{ --> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On top of the comment, no need to include xml:id for (all of the) examples. |
||
| <title><function>sodium_bin2base64</function> example</title> | ||
| <programlisting role="php"> | ||
| <![CDATA[ | ||
| <?php | ||
| $string = 'This is an encoded string'; | ||
| echo sodium_bin2base64($string, SODIUM_BASE64_VARIANT_ORIGINAL); | ||
| ?> | ||
| ]]> | ||
| </programlisting> | ||
| &example.outputs; | ||
| <screen> | ||
| <![CDATA[ | ||
| VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw== | ||
| ]]> | ||
| </screen> | ||
| </example><!-- }}} --> | ||
|
|
||
| <example xml:id="sodium-bin2base64.example.id"><!-- {{{ --> | ||
| <title>Example of the <parameter>id</parameter> parameter</title> | ||
| <programlisting role="php"> | ||
| <![CDATA[ | ||
| <?php | ||
| $binaryString = sodium_hex2bin('aeb6798fef4e5184ff3b5596af753487'); | ||
| var_dump(sodium_bin2base64($binaryString, SODIUM_BASE64_VARIANT_ORIGINAL)); | ||
| var_dump(sodium_bin2base64($binaryString, SODIUM_BASE64_VARIANT_ORIGINAL_NO_PADDING)); | ||
| var_dump(sodium_bin2base64($binaryString, SODIUM_BASE64_VARIANT_URLSAFE)); | ||
| var_dump(sodium_bin2base64($binaryString, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING)); | ||
| ?> | ||
| ]]> | ||
| </programlisting> | ||
| &example.outputs; | ||
| <screen> | ||
| <![CDATA[ | ||
| string(24) "rrZ5j+9OUYT/O1WWr3U0hw==" | ||
| string(22) "rrZ5j+9OUYT/O1WWr3U0hw" | ||
| string(24) "rrZ5j-9OUYT_O1WWr3U0hw==" | ||
| string(22) "rrZ5j-9OUYT_O1WWr3U0hw" | ||
| ]]> | ||
| </screen> | ||
| </example><!-- }}} --> | ||
| </refsect1><!-- }}} --> | ||
|
|
||
| <refsect1 role="seealso"><!-- {{{ --> | ||
| &reftitle.seealso; | ||
| <simplelist> | ||
| <member><function>base64_encode</function></member> | ||
| <member><function>sodium_base642bin</function></member> | ||
| <member><function>sodium_hex2bin</function></member> | ||
| </simplelist> | ||
| </refsect1><!-- }}} --> | ||
|
|
||
| </refentry> | ||
| <!-- Keep this comment at the end of the file | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -76,6 +76,7 @@ VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw== | |||||||||||||
| <para> | ||||||||||||||
| <simplelist> | ||||||||||||||
| <member><function>base64_decode</function></member> | ||||||||||||||
| <member><function>sodium_bin2base64</function></member> | ||||||||||||||
| <member><function>chunk_split</function></member> | ||||||||||||||
| <member><function>convert_uuencode</function></member> | ||||||||||||||
|
Comment on lines
+79
to
81
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| <member><link xlink:href="&url.rfc;2045">RFC 2045</link> section 6.8</member> | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please remove all the comments in this file?
<!-- {{{ -->, etc. In the past this was used more often but nowadays we try to avoid it as it makes the XML harder to read.