Skip to content

Instantly share code, notes, and snippets.

@kingster
Created March 18, 2022 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kingster/1954ead3c38a40cac88c5c1311bb39c5 to your computer and use it in GitHub Desktop.
Save kingster/1954ead3c38a40cac88c5c1311bb39c5 to your computer and use it in GitHub Desktop.
Cryptopp Brew Formula
# Based on https://raw.githubusercontent.com/Homebrew/linuxbrew-core/f204b6b30d3981259a764a29dca1a4b403524c9d/Formula/cryptopp.rb
class Cryptopp < Formula
desc "Free C++ class library of cryptographic schemes"
homepage "https://www.cryptopp.com/"
url "https://github.com/weidai11/cryptopp/archive/CRYPTOPP_8_1_0.tar.gz"
sha256 "8a4e4773a39b0c07d7cea1b8be7a3f7a9d126bd3ac9a9f072f82d3a53a474a87"
license "BSD-3-Clause"
# https://cryptopp.com/wiki/Config.h#Options_and_Defines
def install
system "make", "shared", "all", "CXX=#{ENV.cxx}"
system "./cryptest.exe", "v"
system "make", "install", "PREFIX=#{prefix}"
end
test do
(testpath/"test.cpp").write <<~EOS
#include <cryptopp/sha.h>
#include <string>
using namespace CryptoPP;
using namespace std;
int main()
{
byte digest[SHA1::DIGESTSIZE];
string data = "Hello World!";
SHA1().CalculateDigest(digest, (byte*) data.c_str(), data.length());
return 0;
}
EOS
system ENV.cxx, "test.cpp", "-L#{lib}", "-lcryptopp", "-o", "test"
system "./test"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment