Skip to content

feat: add Conversion/base64 algorithm #437

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

Merged
merged 18 commits into from
Nov 19, 2021
Merged

Conversation

paul-leydier
Copy link
Contributor

A basic implementation of the base64 encoding algorithm, based on RFC4648.

@paul-leydier paul-leydier marked this pull request as ready for review November 16, 2021 20:06
@paul-leydier
Copy link
Contributor Author

Hi everyone!

You'll find in my pull request an implementation of base64 encoding/decoding according to RFC4648.

Here are the benchmark results on my computer:

goos: windows
goarch: amd64
pkg: github.com/TheAlgorithms/Go/cipher/base64
cpu: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
BenchmarkEncode
BenchmarkEncode/Hello_World!
BenchmarkEncode/Hello_World!-6         	 7218757	       161.4 ns/op
BenchmarkEncode/Hello_World!a
BenchmarkEncode/Hello_World!a-6        	 4290879	       281.8 ns/op
BenchmarkEncode/Hello_World!ab
BenchmarkEncode/Hello_World!ab-6       	 4653878	       264.1 ns/op
BenchmarkEncode/Empty
BenchmarkEncode/Empty-6                	100000000	        10.60 ns/op
BenchmarkEncode/6
BenchmarkEncode/6-6                    	11310638	       104.9 ns/op
BenchmarkEncode/Lorem_ipsum
BenchmarkEncode/Lorem_ipsum-6          	  260875	      4933 ns/op
BenchmarkDecode
BenchmarkDecode/Hello_World!
BenchmarkDecode/Hello_World!-6         	10344987	       117.4 ns/op
BenchmarkDecode/Hello_World!a
BenchmarkDecode/Hello_World!a-6        	 8759992	       138.0 ns/op
BenchmarkDecode/Hello_World!ab
BenchmarkDecode/Hello_World!ab-6       	 8687486	       137.6 ns/op
BenchmarkDecode/Empty
BenchmarkDecode/Empty-6                	223022956	         5.307 ns/op
BenchmarkDecode/6
BenchmarkDecode/6-6                    	32433220	        38.15 ns/op
BenchmarkDecode/Lorem_ipsum
BenchmarkDecode/Lorem_ipsum-6          	  338247	      3498 ns/op
PASS

Copy link
Member

@tjgurwara99 tjgurwara99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than that everything else seems to be okay.

@paul-leydier
Copy link
Contributor Author

@tjgurwara99 Thanks for the review, useful feedback! I updated the pull request accordingly.

Copy link
Member

@tjgurwara99 tjgurwara99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this, I don't think base64 is a cipher. Its a conversion. Can you move this to the conversion package instead.

@paul-leydier
Copy link
Contributor Author

Thinking about this, I don't think base64 is a cipher. Its a conversion. Can you move this to the conversion package instead.

Indeed I thought about it but saw on the The algorithms website that it was categorized as a Cipher for both C++ and Python (although it is categorized as "conversions" for js), so I used the cipher package for consistency.

But I can definitely move it to the conversion package if you confirm?

@tjgurwara99
Copy link
Member

Yeah, move it to conversion package. Its more appropriate there.

@paul-leydier paul-leydier changed the title feat: add Cipher/base64 algorithm feat: add Conversion/base64 algorithm Nov 18, 2021
@paul-leydier
Copy link
Contributor Author

I moved the code to the conversion package and renamed the function to be more precise, since the package name is not "base64" anymore.

raklaptudirm
raklaptudirm previously approved these changes Nov 19, 2021
@raklaptudirm
Copy link
Member

@tjgurwara99 The README generation is failing.

@tjgurwara99
Copy link
Member

tjgurwara99 commented Nov 19, 2021

Yeah, its generating the documentation fine but is unable to push to the master branch. I'm waiting on the #434 to be merged and see if the changes work. If not we need to create a token specifically for the godocmd - I've asked @siriak for it but am waiting to hear back from him.

@siriak siriak merged commit 6fd8a07 into TheAlgorithms:master Nov 19, 2021
@paul-leydier paul-leydier deleted the base64 branch November 22, 2021 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants