<?php


class Helpers {

    public static function getBWApiKey() {
        $encryptedKey = get_option(Config::BW_PREFIX . 'api_key');
        return $encryptedKey;
    }

    public static function setBWApiKey($key) {
        $encryptedKey = password_hash($key, PASSWORD_BCRYPT);
        return update_option(Config::BW_PREFIX . 'api_key', $encryptedKey);
    }

    public static function verifyBWApiKey($key) {
        $encryptedKey = get_option(Config::BW_PREFIX . 'api_key');
        $check_pass = password_verify($key, $encryptedKey);
        return $check_pass;
    }

    public static function base64ToImage($base64_string, $output_file) {
        $file = fopen($output_file, "wb");
        $data = explode(',', $base64_string);
        fwrite($file, base64_decode($data[1]));
        fclose($file);
        return $output_file;
    }

}
