Top Related Projects
[Unmaintained] Open source two-factor authentication for Android
A free, secure and open source app for Android to manage your 2-step verification tokens.
Open source fork of the Google Authenticator Android app
Quick Overview
2FAS Android is an open-source two-factor authentication (2FA) app for Android devices. It provides a secure and user-friendly way to generate time-based one-time passwords (TOTP) for various online accounts, enhancing the security of user authentication.
Pros
- Open-source and free, allowing for community contributions and audits
- User-friendly interface with a clean, modern design
- Supports a wide range of services and platforms for 2FA
- Includes advanced features like backup and sync capabilities
Cons
- Limited to Android devices, not available for iOS or other platforms
- Requires manual setup for each service, which can be time-consuming
- May not support some less common or proprietary 2FA implementations
- Depends on the device's clock accuracy for TOTP generation
Getting Started
To use 2FAS Android:
- Download the app from the Google Play Store or build it from source.
- Open the app and follow the initial setup instructions.
- To add a new account:
- Tap the "+" button
- Scan the QR code provided by the service you're setting up 2FA for
- Alternatively, enter the secret key manually
- Use the generated codes when logging into your accounts that have 2FA enabled.
For developers who want to contribute:
- Clone the repository:
git clone https://github.com/twofas/2fas-android.git
- Open the project in Android Studio.
- Build and run the app on an emulator or physical device.
- Make your changes and submit a pull request following the project's contribution guidelines.
Competitor Comparisons
[Unmaintained] Open source two-factor authentication for Android
Pros of andOTP
- Open-source and fully free, with no proprietary components
- Supports encrypted backups and export options
- Offers advanced features like custom icons and tags for better organization
Cons of andOTP
- Less user-friendly interface compared to 2FAS
- Limited cross-platform support (Android-only)
- Fewer customization options for the app's appearance
Code Comparison
andOTP uses Kotlin for its Android implementation:
class TOTPHelper {
fun generateTOTP(secret: String, time: Long, digits: Int, algorithm: String): String {
val hmac = Mac.getInstance(algorithm)
hmac.init(SecretKeySpec(Base32().decode(secret), algorithm))
val hash = hmac.doFinal(ByteBuffer.allocate(8).putLong(time / 30000).array())
val offset = hash[hash.size - 1].toInt() and 0xf
val binary = ByteBuffer.wrap(hash).getInt(offset) and 0x7fffffff
return String.format("%0${digits}d", binary % 10.pow(digits))
}
}
2FAS Android uses Java:
public class TOTPGenerator {
public static String generateTOTP(String secret, long time, int digits, String algorithm) {
byte[] key = Base32.decode(secret);
byte[] data = ByteBuffer.allocate(8).putLong(time / 30000).array();
byte[] hash = HmacUtils.hmac(algorithm, key, data);
int offset = hash[hash.length - 1] & 0xf;
int binary = ByteBuffer.wrap(hash).getInt(offset) & 0x7fffffff;
return String.format("%0" + digits + "d", binary % (int) Math.pow(10, digits));
}
}
Both implementations follow similar logic for TOTP generation, with minor differences in language-specific syntax and method names.
A free, secure and open source app for Android to manage your 2-step verification tokens.
Pros of Aegis
- Open-source and fully auditable, enhancing trust and security
- Supports a wider range of 2FA methods, including HOTP and Steam
- More customization options for the user interface
Cons of Aegis
- Less intuitive user interface for beginners
- Lacks built-in cloud backup and sync features
- Smaller user base, potentially leading to slower development and updates
Code Comparison
Both projects are written in Kotlin for Android development. Here's a brief comparison of their code structure:
2FAS Android:
class TotpTokenGenerator(private val secret: String) {
fun generate(timestamp: Long): String {
// TOTP generation logic
}
}
Aegis:
class TOTPGenerator(private val secret: ByteArray) : OTPGenerator {
override fun generate(counter: Long): String {
// TOTP generation logic
}
}
Both implementations follow similar patterns for OTP generation, with Aegis using a more generic approach through an interface.
Pros of FreeOTP
- Open-source and maintained by Red Hat, providing a high level of trust and security
- Lightweight and simple interface, focusing on core OTP functionality
- Supports both HOTP and TOTP protocols
Cons of FreeOTP
- Limited feature set compared to 2FAS
- Less frequent updates and potentially slower development cycle
- Fewer customization options for users
Code Comparison
FreeOTP:
public class Token implements Comparable<Token> {
public static final String TOTP = "totp";
public static final String HOTP = "hotp";
private String issuerInt;
private String issuerExt;
private String label;
private String imageUrl;
}
2FAS:
data class Service(
@PrimaryKey val id: String = UUID.randomUUID().toString(),
val name: String,
val secret: String,
val serviceTypeId: Long,
val otpLink: String? = null,
val otpLabel: String? = null,
val otpAccount: String? = null,
val otpIssuer: String? = null,
val otpDigits: Int = 6,
val otpPeriod: Int = 30,
val otpAlgorithm: String = "SHA1",
val backupSyncStatus: BackupSyncStatus = BackupSyncStatus.NOT_SYNCED,
val updatedAt: Long = System.currentTimeMillis(),
val badgeColor: Int? = null,
val selectedImageType: SelectedImageType = SelectedImageType.IconCollection,
val iconCollectionId: String? = null,
val labelText: String? = null,
val labelColor: Int? = null,
val groupId: String? = null,
val isDeleted: Boolean = false
)
The code comparison shows that 2FAS offers a more comprehensive data model for services, including additional features like backup sync status, badge colors, and grouping options, while FreeOTP focuses on essential OTP token information.
Open source fork of the Google Authenticator Android app
Pros of Google Authenticator
- Developed and maintained by Google, ensuring high security standards and regular updates
- Simple and straightforward user interface, making it easy for beginners to use
- Lightweight app with minimal resource usage
Cons of Google Authenticator
- Limited features compared to 2FAS, lacking advanced options like custom icons or categories
- No built-in backup or sync functionality, making it challenging to transfer accounts between devices
- Less frequent updates and slower adoption of new features
Code Comparison
Google Authenticator uses a more traditional approach to generating TOTP codes:
long time = System.currentTimeMillis() / 1000 / 30;
byte[] data = new byte[8];
for (int i = 8; i-- > 0; time >>>= 8) {
data[i] = (byte) time;
}
2FAS implements a more modern and flexible approach:
fun generateCode(secret: String, time: Long): String {
val hmac = Mac.getInstance("HmacSHA1")
hmac.init(SecretKeySpec(secret.toByteArray(), "RAW"))
val hash = hmac.doFinal(ByteBuffer.allocate(8).putLong(time / 30).array())
val offset = hash[hash.size - 1].toInt() and 0xf
val truncatedHash = hash.copyOfRange(offset, offset + 4)
return (ByteBuffer.wrap(truncatedHash).int and 0x7fffffff % 1000000).toString().padStart(6, '0')
}
Both implementations achieve the same goal, but 2FAS's code is more readable and flexible, allowing for easier customization and extension.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Open Source 2FAS for Android
This is the official Android app for the Open Source 2FAS project.
What is 2FAS?
2FAS (Two-Factor Authentication Service) is a user authentication method that provides an additional layer of security for online accounts. In addition to a username and password, 2FAS uses a second factor, such as a one-time password (OTP) shown on a user's phone, to verify a user's identity. This helps prevent unauthorized access to accounts, even if a password is compromised.
Features
- Support for time-based one-time passwords (TOTP) and HMAC-based on-time passwords (HOTP)
- Compatible with any service that supports the TOTP and HOTP standard, including Google, Microsoft, and Dropbox
- Easy to set up and use
Graphics
Please note that the graphics used in this app are not part of the open source project and are subject to their own separate licensing terms.
Bug Reporting
We use GitHub for bug reports. Please visit the 2FAS for Android issues page to search for and report any bugs you may have found. Before adding a new issue, please search for existing issues to avoid duplicates.
For reporting security issues only, please send a detailed description of the vulnerability to security@2fas.com. Do not use this address for general inquiries or bug reports unrelated to security concerns.
Getting Started
- Download the app from the releases page.
- Install the app on your Android device.
- Follow the on-screen instructions to set up 2FAS for your online accounts.
Contributing
We welcome contributions to the Open Source 2FAS project. If you would like to contribute, please see the contribution guide.
Donations
If you would like to support the development of the Open Source 2FAS project, you can make a donation. All donations will be used to support the ongoing development and maintenance of the project.
We appreciate your support!
License
Copyright (c) Two Factor Authentication Service, Inc. All rights reserved.
Licensed under the GNU General Public License v3.0.
Top Related Projects
[Unmaintained] Open source two-factor authentication for Android
A free, secure and open source app for Android to manage your 2-step verification tokens.
Open source fork of the Google Authenticator Android app
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot