From 8c05e6682f2fefc0f65f555696cdd9a7dcb04f08 Mon Sep 17 00:00:00 2001
From: Filippo Tessarotto <zoeslam@gmail.com>
Date: Thu, 13 Oct 2022 15:19:01 +0200
Subject: [PATCH] Update Doc

---
 doc/AppConfig.md | 10 +++++-----
 doc/Customize.md | 26 ++++++++++----------------
 doc/QA.md        |  4 ++--
 doc/index.md     |  6 +++---
 4 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/doc/AppConfig.md b/doc/AppConfig.md
index 2cfdba5..5f2a4ef 100644
--- a/doc/AppConfig.md
+++ b/doc/AppConfig.md
@@ -15,7 +15,7 @@ You just have to:
 <?php
 use OTPHP\TOTP;
 
-$totp = TOTP::create('JBSWY3DPEHPK3PXP'); // New TOTP with custom secret
+$totp = TOTP::createFromSecret('JBSWY3DPEHPK3PXP'); // New TOTP with custom secret
 $totp->setLabel('alice@google.com'); // The label (string)
 
 $totp->getProvisioningUri(); // Will return otpauth://totp/alice%40google.com?secret=JBSWY3DPEHPK3PXP
@@ -34,7 +34,7 @@ Hereafter two examples using the Google Chart API (this API is deprecated since
 <?php
 use OTPHP\TOTP;
 
-$totp = TOTP::create(); // New TOTP
+$totp = TOTP::generate(); // New TOTP
 $totp->setLabel('alice@google.com'); // The label (string)
 
 $google_chart = $totp->getQrCodeUri('https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl={PROVISIONING_URI}', '{PROVISIONING_URI}');
@@ -48,7 +48,7 @@ Please note that this URI MUST contain a placeholder for the OTP Provisioning UR
 <?php
 use OTPHP\TOTP;
 
-$totp = TOTP::create(); // New TOTP
+$totp = TOTP::generate(); // New TOTP
 $totp->setLabel('alice@google.com'); // The label (string)
 
 $goqr_me = $totp->getQrCodeUri(
@@ -74,7 +74,7 @@ Now run the following and compare the output
 <?php
 use OTPHP\TOTP;
 
-$totp = TOTP::create('JBSWY3DPEHPK3PXP'); // New TOTP with custom secret
+$totp = TOTP::createFromSecret('JBSWY3DPEHPK3PXP'); // New TOTP with custom secret
 $totp->setLabel('alice@google.com'); // The label (string)
 
 echo 'Current OTP: ' . $totp->now();
@@ -92,7 +92,7 @@ Now run the following and compare the output
 <?php
 use OTPHP\TOTP;
 
-$totp = TOTP::create(
+$totp = TOTP::createFromSecret(
     'JBSWY3DPEHPK3PXP', // New TOTP with custom secret
     10,                 // The period (int)
     'sha512',           // The digest algorithm (string)
diff --git a/doc/Customize.md b/doc/Customize.md
index 34d6619..db57894 100644
--- a/doc/Customize.md
+++ b/doc/Customize.md
@@ -21,7 +21,7 @@ use OTPHP\TOTP;
 use ParagonIE\ConstantTime\Base32;
 
 $mySecret = trim(Base32::encodeUpper(random_bytes(128)), '='); // We generate our own 1024 bits secret
-$otp = TOTP::create($mySecret);
+$otp = TOTP::createFromSecret($mySecret);
 ```
 
 *Please note that the trailing `=` are automatically removed by the library.*
@@ -35,13 +35,11 @@ By default, the period for a TOTP is 30 seconds and the counter for a HOTP is 0.
 use OTPHP\TOTP;
 use OTPHP\HOTP;
 
-$otp = TOTP::create(
-    null, // Let the secret be defined by the class
+$otp = TOTP::generate(
     10    // The period is now 10 seconds
 );
 
-$otp = HOTP::create(
-    null, // Let the secret be defined by the class
+$otp = HOTP::generate(
     1000  // The counter is now 1000. We recommend you start at `0`, but you can set any value (at least 0)
 );
 ```
@@ -59,8 +57,7 @@ You must verify that the algorithm you want to use is supported by the applicati
 <?php
 use OTPHP\TOTP;
 
-$totp = TOTP::create(
-    null,       // Let the secret be defined by the class
+$totp = TOTP::generate(
     30,         // The period (30 seconds)
     'ripemd160' // The digest algorithm
 );
@@ -75,8 +72,7 @@ You can decide to use more (or less) digits. More than 10 may be difficult to us
 <?php
 use OTPHP\TOTP;
 
-$totp = TOTP::create(
-    null,   // Let the secret be defined by the class
+$totp = TOTP::generate(
     30,     // The period (30 seconds)
     'sha1', // The digest algorithm
     8       // The output will generate 8 digits
@@ -100,8 +96,7 @@ example encode the timestamp in the secret to make it different each time.
 use OTPHP\TOTP;
 
 // Without epoch
-$otp = TOTP::create(
-    null, // Let the secret be defined by the class
+$otp = TOTP::generate(
     5,     // The period (5 seconds)
     'sha1', // The digest algorithm
     6      // The output will generate 6 digits
@@ -113,8 +108,7 @@ $otp->verify($password, 1519401289); // Second 1: true
 $otp->verify($password, 1519401290); // Second 2: false
 
 // With epoch
-$otp = TOTP::create(
-    null, // Let the secret be defined by the class
+$otp = TOTP::generate(
     5,     // The period (5 seconds)
     'sha1', // The digest algorithm
     6,      // The output will generate 6 digits
@@ -140,7 +134,7 @@ These parameters are available in the provisioning URI or from the method `getPa
 <?php
 use OTPHP\TOTP;
 
-$totp = TOTP::create('JBSWY3DPEHPK3PXP'); // New TOTP
+$totp = TOTP::createFromSecret('JBSWY3DPEHPK3PXP'); // New TOTP
 $totp->setLabel('alice@google.com'); // The label
 $totp->setParameter('foo', 'bar');
 
@@ -156,7 +150,7 @@ it is useful to set the issuer parameter to identify the service that provided t
 <?php
 use OTPHP\TOTP;
 
-$totp = TOTP::create('JBSWY3DPEHPK3PXP'); // New TOTP with custom secret
+$totp = TOTP::createFromSecret('JBSWY3DPEHPK3PXP'); // New TOTP with custom secret
 $totp->setLabel('alice@google.com'); // The label (string)
 $totp->setIssuer('My Service');
 ```
@@ -187,7 +181,7 @@ Some applications such as FreeOTP can load images from an URI (`image` parameter
 <?php
 use OTPHP\TOTP;
 
-$totp = TOTP::create('JBSWY3DPEHPK3PXP'); // New TOTP with custom secret
+$totp = TOTP::createFromSecret('JBSWY3DPEHPK3PXP'); // New TOTP with custom secret
 $totp->setLabel('alice@google.com'); // The label (string)
 $totp->setParameter('image', 'https://foo.bar/otp.png');
 
diff --git a/doc/QA.md b/doc/QA.md
index 75e81c0..369d9c1 100644
--- a/doc/QA.md
+++ b/doc/QA.md
@@ -24,7 +24,7 @@ $digits = 6;
 $digest = 'sha1';
 $period = 30;
 
-$totp = TOTP::create(
+$totp = TOTP::createFromSecret(
     $user->getOtpSecret(),
     $period,
     $digest,
@@ -76,7 +76,7 @@ If you try the following code lines, you may see 2 different OTPs.
 <?php
 use OTPHP\TOTP;
 
-$totp = TOTP::create(null, 10); // TOTP with an 10 seconds period
+$totp = TOTP::generate(10); // TOTP with an 10 seconds period
 
 for ($i = 0; $i < 10; $i++) {
     echo 'Current OTP is: '. $totp->now();
diff --git a/doc/index.md b/doc/index.md
index 1eb4216..a727ae8 100644
--- a/doc/index.md
+++ b/doc/index.md
@@ -42,13 +42,13 @@ use OTPHP\TOTP;
 
 // A random secret will be generated from this.
 // You should store the secret with the user for verification.
-$otp = TOTP::create();
+$otp = TOTP::generate();
 echo "The OTP secret is: {$otp->getSecret()}\n";
 
 // Note: use your own way to load the user secret.
 // The function "load_user_secret" is simply a placeholder.
 $secret = load_user_secret();
-$otp = TOTP::create($secret);
+$otp = TOTP::createFromSecret($secret);
 echo "The current OTP is: {$otp->now()}\n";
 ```
 
@@ -74,7 +74,7 @@ echo "<img src='{$grCodeUri}'>";
 Now that your applications are configured, you can verify the generated OTPs:
 
 ```php
-$otp = TOTP::create($secret); // create TOTP object from the secret.
+$otp = TOTP::createFromSecret($secret); // create TOTP object from the secret.
 $otp->verify($input); // Returns true if the input is verified, otherwise false.
 ```
 
-- 
GitLab