In Trunk-based development, ensuring the integrity and authenticity of images is crucial. This can be achieved by signing the images and later verifying them when pulling images from the repository. Below is a simple example of how to sign and verify images using a public/private key pair.
// Create a private key
$privateKey = openssl_pkey_new();
openssl_pkey_export($privateKey, $privateKeyOut);
// Generate a public key
$publicKey = openssl_pkey_get_details($privateKey)['key'];
// The image data to be signed
$imageData = 'Sample Image Data';
// Sign the image data
openssl_sign($imageData, $signature, $privateKeyOut, OPENSSL_ALGO_SHA256);
// To verify the image signature
$isValidSignature = openssl_verify($imageData, $signature, $publicKey, OPENSSL_ALGO_SHA256);
if($isValidSignature === 1) {
echo "Signature is valid.";
} elseif($isValidSignature === 0) {
echo "Signature is invalid.";
} else {
echo "Error verifying signature.";
}
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?